package com.ryx.exception;

import com.ryx.exception.code.ResponseCodeInterface;

/**
 * @BelongsPackage: com.ryx.exception
 * @Author: 容永轩
 * @CreateTime: 2020-10-26
 * @Description:
 */
public class GlobalException extends RuntimeException{



    private final int code;


    private final String msg;


    public GlobalException(int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    //通过枚举接口的get和set拿到参数，然后调用上面的构造方法
    public GlobalException(ResponseCodeInterface responseCodeInterface){
        this(responseCodeInterface.getCode(),responseCodeInterface.getMsg());
    }


    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
